<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.hhwy.sso.client.filter.SessionUtil" %>
<%@taglib prefix="shiro"  uri="/WEB-INF/ac.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="${Config.staticURL}plugins/miniui/boot.js" type="text/javascript"></script>
    <script type="text/javascript"src="${Config.staticURL}/lib/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="${Config.staticURL}plugins/miniui/table.css">
    <script src="${Config.basePath}plugins/miniui/fileupload/js/ajaxfileupload.js" type="text/javascript"></script>
    <title> -编辑</title>
</head>

<body class="body">
<form action="" id="form1">

    <table border="0" align="center" cellpadding="0" cellspacing="0" class="tab_form">
        <TBODY>
	        <tr>
	            <td class="title" colspan="4">
	              	  -编辑	              	  
	            </td>
	             <input id="id" name="id" class="mini-textbox" style="display:none;"/>
	        </tr>
 			<tr>
					<td class="l">
	              		address
	            </td>
				<td class="r">
				          <input id="address" name="address" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	birthday
		        </td>
				<td class="r">
	        			<input id="birthday" name="birthday" class="mini-datepicker mini-textbox"
					
					 allowInput="false"
				     format="yyyy-MM-dd" 
				     indentSpace="true" 
			         onvalidation="onValidation" 
			         selectOnFocus="true"
			         required="true" 
			         errorMode="border" 
	                 showTime="false"/>
			
				              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		code
	            </td>
				<td class="r">
				          <input id="code" name="code" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	email
		        </td>
				<td class="r">
	        			
	          <input id="email" name="email" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		idcard
	            </td>
				<td class="r">
				          <input id="idcard" name="idcard" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	loginName
		        </td>
				<td class="r">
	        			
	          <input id="loginName" name="loginName" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		mobile
	            </td>
				<td class="r">
				          <input id="mobile" name="mobile" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	password
		        </td>
				<td class="r">
	        			
	          <input id="password" name="password" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		photo
	            </td>
				<td class="r">
				          <input id="photo" name="photo" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	qq
		        </td>
				<td class="r">
	        			
	          <input id="qq" name="qq" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		sex
	            </td>
				<td class="r">
				          <input id="sex" name="sex" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	tel
		        </td>
				<td class="r">
	        			
	          <input id="tel" name="tel" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	
 			<tr>
					<td class="l">
	              		userName
	            </td>
				<td class="r">
				          <input id="userName" name="userName" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	         	              	<span style="color: red;">*</span>
	            </td>
				<td class="l">
		            	wx
		        </td>
				<td class="r">
	        			
	          <input id="wx" name="wx" class="mini-textbox"
		                indentSpace="true" 
		                onvalidation="onValidation" 
		                selectOnFocus="true"
		                allowInput="true" 
		                required="true" 
		                errorMode="border" 
	                />
	          	              	<span style="color: red;">*</span>
	            </td>
	    	</tr>
	    	
	    	

        </TBODY>
    </table>

    <div style="text-align:center;padding-top:8px;padding-bottom:8px;" borderStyle="border:0;">
        <a class="mini-button" style="width:60px;" onclick="submitForm()">确定</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="mini-button" style="width:60px;" onclick="goback()">取消</a>
    </div>
</form>

<script type="text/javascript">
	var basePath = '${Config.baseURL}';
    mini.parse();
    var form = new mini.Form("#form1");
    $.ajax({
        url: "${Config.basePath}user/" + getRequestArgs()["id"],
        type: "get",
        async: false,
        success: function (text) {
            var data = mini.decode(text);   //反序列化成对象
            form.setData(data);             //设置多个控件数据
            // labelModel();
        }
    });
    
     //取得跳转的参数 返回JSON格式
    function getRequestArgs() {
        var url = location.search;
        //获取url中"?"符后的字串
        var args = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");

            for (var i = 0; i < strs.length; i++) {
                args[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
            }
        }
        return args;
    }
    
    function updateError(e) {
            var id = e.sender.name + "_error";
            var el = document.getElementById(id);
            if (el) {
                el.innerHTML = e.errorText;
            }
        }
     function onValidation(e) {                  
            updateError(e);
     }
    
    function submitForm() {

      //提交表单数据
      var form = new mini.Form("#form1");
      //表單验证
      form.validate();
      if (form.isValid() == false) return;

        var data = form.getData(true, true);      //获取表单多个控件的数据
        var json = mini.encode(data);   //序列化成JSON
        $.ajax({
            url: "${Config.basePath}user/updateUser",
            type: "PUT",
            contentType: "application/json;charset=UTF-8",
            dataType: "json", //表示返回值类型，不必须
            data: json,
            success: function (text) {
                goback();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
               mini.alert("发生异常");
            }
        });

    }
    
    //返回列表页面
    
    function goback() {
        window.location.href = "${Config.basePath}/view/epc/user/userList";
    }
     
</script>
</body>
</html>